

#ifndef CODE_ANALYZER_H_INCLUDED
#define CODE_ANALYZER_H_INCLUDED

#include "asyncprocess.h"
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include <cbplugin.h> 
struct LangData
{
    LangData() {regexp_indfile=1;regexp_indline=2;regexp_indmsg=3;}
    wxString command;
    wxString regexp;
    int regexp_indfile;
    int regexp_indline;
    int regexp_indmsg;
};

typedef std::map<int,LangData> Languages;

struct CodeIssue
{
    int line;
    wxString msg;
};

typedef std::vector<CodeIssue> CodeIssues;

struct ProcessQueueItems
{
    wxString file;
    int lang;
};

typedef std::list<ProcessQueueItems> ProcessQueue;

// The core data for this plugin maps the open files (using full path) to a list of issues
typedef std::map<wxString,CodeIssues> OpenCodeIssues;


class CodeChecker : public cbPlugin
{
    public:
        
        CodeChecker();
        
        virtual ~CodeChecker();

        
        virtual int Configure();

        
        void OnAnalyze(CodeBlocksEvent &e);

        void OnTooltip(CodeBlocksEvent& e);

        
        void OnQueueTimer(wxTimerEvent &e);

        
        void OnProcessTerminate(wxProcessEvent &e);

        
        virtual int GetConfigurationPriority() const { return 50; }

        
        virtual int GetConfigurationGroup() const { return cgUnknown; }

        
        virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow* parent){ return 0; }

        
        virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow* parent, cbProject* project){ return 0; }

        
        virtual void BuildMenu(wxMenuBar* menuBar);

        
        virtual void BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data = 0);

        
        virtual bool BuildToolBar(wxToolBar* toolBar);
    protected:
        
        virtual void OnAttach();

        
        virtual void OnRelease(bool appShutDown);

    private:
        DECLARE_EVENT_TABLE();
        OpenCodeIssues m_issues;
        AsyncProcess *m_process;
        ProcessQueue m_processqueue;
        Languages m_commands;
        wxString m_activefile;
        wxTimer m_queuetimer;
        wxString m_process_out, m_process_err;
};

#endif // CODE_ANALYZER_H_INCLUDED
